#### Generate Figure: AMCE by Income/Education Levels ####

fig3_dat = bind_rows(import(here("data","fig3_inc_dat.rds")) |> 
                       mutate(demo = "Income"),
                     import(here("data","fig3_edu_dat.rds")) |> 
                       mutate(demo = "Education")) |> 
  invert_group() |> fix_healthcare()

fig_inc = plot_conjoint(conjoint = fig3_dat |> 
                           filter(demo == "Income"),
                         is_result = T,
                         lab = policies, 
                         weights = dta_grp$demog_weight[!is.na(dta_grp$inc_grp)],
                         use="all",
                         title=NULL,
                         grouped_data=T) +
  labs(subtitle = "Income", x = NULL, y = NULL)

fig_edu = plot_conjoint(conjoint = fig3_dat |> 
                           filter(demo == "Education"),
                         is_result = T,
                         lab = policies, 
                         weights = dta_grp$demog_weight[!is.na(dta_grp$edu_grp)],
                         use="all",
                         color_set=c("1"="grey","2"="black","3"="lightgreen","4"="darkgreen"),
                         title=NULL,
                         grouped_data=T) +
  labs(subtitle = "Education", x = NULL, y = NULL)

fig_inc_edu = fig_inc + fig_edu

print(fig_inc_edu)

ggsave(here("figures","figure_3.png"), fig_inc_edu,
       dpi = 600, units = "in", width = 10, height = 9)

ccat("See 'figure_3.png' for Figure 3 output")


